﻿using SarahShop.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SarahShop.Controllers
{
    public class HomeController : Controller
    {
        DataAccess.Data dataAccess = new DataAccess.Data();

        public ActionResult Index()
        {
            dataAccess = new DataAccess.Data();
            List<Slider> _lstSlider = dataAccess.getSliders();
            List<Product> _lstProduct = dataAccess.getProducts();
            IndexModel model = new IndexModel();
            model.lstProduct = _lstProduct;
            model.lstSlider = _lstSlider;
            return View(model);
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        public ActionResult Blog()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }


        public ActionResult Details(string pCode)
        {
            dataAccess = new DataAccess.Data();
            Product _product = dataAccess.getProduct(pCode);
            List<Product> random = dataAccess.random3Product();
            ViewBag.randomProduct = random;
            return View(_product);
        }

        public ActionResult Login()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        public ActionResult Products()
        {
            dataAccess = new DataAccess.Data();
            List<Product> _lstProduct = dataAccess.getProducts();
            return View(_lstProduct);
        }
    }
}
